package com.yix.demo;

import com.yix.util.DBUtil;

import java.sql.Connection;
import java.sql.Statement;

public class TableSpaceDemo {
    public static void main(String[] args) {
        createTableSpace("my_tablespace", "/path/to/your/directory");

    }

    /**
     * 创建表空间
     *
     * @param tableSpaceName
     * @param path
     */
    private static void createTableSpace(String tableSpaceName, String path) {
        String createTablespaceSQL = "create tablespace " + tableSpaceName + " location '" + path + "';";
        try (Connection conn = DBUtil.getPGConnection();
             Statement stmt = conn.createStatement()) {
            stmt.execute(createTablespaceSQL);
            System.out.println("表空间 '" + tableSpaceName + "' 创建成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
